<template>
  <el-col :span="24">
<viewTitle text="基本信息" style="font-size:20px;" />
        <div class="separate" style="marginTop:20px;">
            <el-descriptions direction="horizontal" :column="8" size='small'  border>
          <el-descriptions-item label="姓名"> {{patientinfo2.name?patientinfo2.name:""}}</el-descriptions-item>
          <el-descriptions-item label="性别">{{patientinfo2.gender?patientinfo2.gender:""}}</el-descriptions-item>
          <el-descriptions-item label="年龄">{{patientinfo2.age?patientinfo2.age:""}}岁</el-descriptions-item>
         
          <el-descriptions-item label="床位">{{patientinfo2.room_infoname?patientinfo2.room_infoname:""}}</el-descriptions-item>
          <el-descriptions-item label="住院号">{{patientinfo2.ipt_no}}</el-descriptions-item>
         
          <el-descriptions-item label="身份证">{{patientinfo2.id_card}}</el-descriptions-item>
          <!-- <el-descriptions-item label="陪护人">{{patientinfo2.family_name}}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="陪护人联系">{{patientinfo2.family_phone}}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="科室">{{patientinfo2.dept.name?patientinfo2.dept.name:""}}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="护理等级">{{patientinfo2.nurse_level_name?patientinfo2.nurse_level_name:""}}</el-descriptions-item>
          <el-descriptions-item label="风险等级">{{patientinfo2.risk_level}}</el-descriptions-item>
          <el-descriptions-item label="病人性质">{{patientinfo2.memberNature?patientinfo2.memberNature:""}}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="科室">{{user.deptName}}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="经治医生">{{patientinfo2.doctor.real_name?patientinfo2.doctor.real_name:''}}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="入院天数">{{patientinfo2.day}}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="可用押金">{{patientinfo2.wallet.wallet_money}}</el-descriptions-item>
          <el-descriptions-item label="已交押金">{{patientinfo2.wallet.wallet_income }}</el-descriptions-item> -->
          <!-- <el-descriptions-item label="备注" :span="4">{{patientinfo2.adm_diag_dscr}}</el-descriptions-item> -->
       <!-- <el-descriptions-item label="入院诊断" :span="24">{{patientinfo2.diseaseName?patientinfo2.diseaseName:""}}</el-descriptions-item> -->
        </el-descriptions>
       
        </div>
           
  </el-col>
</template>

<script>

import ViewTitle from "@/forComponents/viewTitle";
import {readHospitalMemberDetail,getNurseLevel} from "@/api/zhuyanre"
import { getdictIndex } from "@/api/register";
export default {
  name:"costsRecord",
  props: ["id"],
  data(){
    return {
     yinshi:[],
     huli:[],
     patientinfo2:{
      
       nurse_levelneme: "",
        member: {
          name: "",
          gender: "",
          age: ""
        },
        wallet: {
          wallet_income: ""
        },
        doctor: { real_name: "" },
        nurse: { real_name: "" },
        room_name: "",
        dept:{name:''},

     }
    }
  },
   watch: {
    //  console.log( this.userdata,'000000')
    id(n) {
        console.log(n,"id变了")
         this.readHospitalMemberDetail(n)
    }},
  mounted(){
    this.getdictIndex()
    this.getNurseLevel()
    console.log("进入",this.id)
    if(typeof(this.id)=="undefined"){
      
    }else{
      this.readHospitalMemberDetail(this.id)
    }
    
  },
  methods:{
        getNurseLevel() {
      getNurseLevel({}).then(res => {
        this.huli = res.data;
      });
    },
    getdictIndex(){
          getdictIndex({ group_id: '4,6' }).then(res => {
            let data = res.data;
          data.forEach((item, key) => {
            if(item.id==6){
            
             this.yinshi=item.items;
            }else if (item.id==4) {
              this.member_lv=item.items;
            }
          });
      });
    },
        
      readHospitalMemberDetail(id){
        readHospitalMemberDetail({id:id}).then(res=>{
           if (res.code==200) {

             var objdata={}
        Object.assign(objdata, res.data.masterInfo, res.data.nodeInfo,res.data.member);
        this.patientinfo2=objdata
        this.patientinfo2.room_infoname=''
        if( this.patientinfo2.room_info){
              this.patientinfo2.room_info=objdata.room_name.split('/')
              this.patientinfo2.room_infoname=this.patientinfo2.room_info[3]
        }
      
             this.patientinfo2.gender =
                this.patientinfo2.gender == 1
                  ? "男"
                  : this.patientinfo2.gender == 2
                  ? "女"
                  : "其他";
              // this.patientinfo2.nurse_levelneme = this.mapping(
              //   this.patientinfo2.nurse_level
              // );
               this.patientinfo2.diet_id = this.mapxing(
                this.patientinfo2.diet_id
              );
              
               this.patientinfo2.memberNature=this.mapyin(
                 this.patientinfo2.nature
               )
               if (this.patientinfo2.disease) {
                          this.patientinfo2.diseaseName =  this.patientinfo2.disease.map(item=>{
              return item.disease_name
            })
             this.patientinfo2.diseaseName =  this.patientinfo2.diseaseName.join("&")
               }
                 }
               console.log(this.patientinfo2)
        })
                     
         
      },
      mapping(num) {

      var art = "";
      for (var i in this.huli) {
        if (this.huli[i].id == num) {

          art = this.huli[i].name;
        }
        return art;
      }
    },
 
     mapxing(num) {

      var art = "";
      for (var i in this.yinshi) {
        if (this.yinshi[i].id == num) {

          art = this.yinshi[i].name;
        }
        return art;
      }
    },
        //匹配斌人性质
     mapyin(num) {

      var art = "";
      for (var i in this.member_lv) {
        if (this.member_lv[i].id == num) {

          art = this.member_lv[i].name;
        }
        return art;
      }
    },

  },
  components:{

    ViewTitle,

  }
}
</script>

<style lang='scss' scoped>

.separate {
    .dialog-text {
        font-size: 16px;
        margin-bottom: 16px;
        display: flex;
        justify-content: space-between;
        span{
          display: inline-block;

          text-indent:1em
        }
    }
}
.el-descriptions .is-bordered .el-descriptions-item__cell{
      border: 1px solid #EBEEF5;
      padding: 2px 0px; 

}
</style>